package 文件内容操作;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-10-16
 * Time: 20:50
 */
public class demo7 {
    public static void main(String[] args) throws IOException {
        OutputStream outputStream = new FileOutputStream("./bbb.txt");
        PrintWriter writer = new PrintWriter(outputStream);
        writer.write(97);
        writer.println();
        writer.printf("a = %d\n",10);
        writer.flush();
        outputStream.close();
    }
    public static void main1(String[] args) throws IOException {
        // 针对写文本文件来说, 还可以使用 PrintWriter 来简化开发.
        try (OutputStream outputStream = new FileOutputStream("./bbb.txt")) {
            PrintWriter writer = new PrintWriter(outputStream);

            writer.println();
            writer.printf("a = %d\n", 10);
            writer.flush();
        }
    }
}
